package com.sgb.jicai.viewmodel;

import androidx.lifecycle.ViewModel;

import com.sgb.jicai.base.JiCaiBaseApi;
import com.swgk.core.base.api.ICallBack;
import com.swgk.core.util.PickSelectEntity;
import com.sgb.jicai.entity.JcCountEntity;
import com.sgb.jicai.view.activity.MyCenterXuFangFaQiActivity;
import com.swgk.core.base.model.entity.BaseEntity;
import com.swgk.core.util.MToast;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class MyCenterXuFangFaQiModel  extends ViewModel {

    private MyCenterXuFangFaQiActivity activity;



    public void getFirstTabDatas() {
        List<PickSelectEntity> datas = new ArrayList<>();
        datas.add(new PickSelectEntity("1", "即报即采"));
        datas.add(new PickSelectEntity("2", "汇集采购"));
        activity.updateFirstTabData(datas);
    }

    public List getSecondTabDatas(String type) {
        List<PickSelectEntity> datas = new ArrayList<>();
        if (type.equals("2")) {
            datas.add(new PickSelectEntity("0", "全部"));
            datas.add(new PickSelectEntity("8", "审批中"));
            datas.add(new PickSelectEntity("1", "集采中"));
            datas.add(new PickSelectEntity("9", "已拒绝"));
            datas.add(new PickSelectEntity("2", "集采完成"));
            datas.add(new PickSelectEntity("4", "集采失败"));
        } else {
            datas.add(new PickSelectEntity("0", "全部"));
            datas.add(new PickSelectEntity("8", "审批中"));
            datas.add(new PickSelectEntity("1", "集采中"));
            datas.add(new PickSelectEntity("9", "已拒绝"));
            datas.add(new PickSelectEntity("2", "集采完成"));
        }
        return datas;
    }

    /**
     * 刷新数量
     */
    public void getMyGroupBuyListCount(String groupBuyType,String groupBuyMode, String searchWords) {
        Map map = new HashMap();
        map.put("groupBuyType", groupBuyType);
        map.put("groupBuyMode", groupBuyMode);//1需方发起 2企业专项
        map.put("goodsName", searchWords);
        JiCaiBaseApi.getApi().getMyGroupBuyingCountForStatus(map).enqueue(new ICallBack<BaseEntity<List<JcCountEntity>>>() {
            @Override
            public void onSuccess(BaseEntity<List<JcCountEntity>> data) {
                if (data.getData() == null ||data.getState() == null) {
                    return;
                }
                if (data.getState().equals(JiCaiBaseApi.RESPONSE_OK)) {
                    activity.setTabNum(data.getData());
                } else {
                    MToast.showToast(activity, data.getMsg());
                }
            }
        });
    }


    public void setActivity(MyCenterXuFangFaQiActivity myCenterXuFangFaQiActivity) {
        this.activity = myCenterXuFangFaQiActivity;
    }
}
